<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Models\Information;
use App\Transformers\InformationTransformer;

class InformationsController extends Controller
{
    /** [index 项目信息列表] */
    public function index()
    {
    	return $this->response->collection(Information::all(), new InformationTransformer());
    }


    public function show(Information $information)
    {
    	return $this->response->item($information, new InformationTransformer());
    }

    /** [store 新增] */
    public function store(Request $request, Information $information)
    {
    	$information->fill($request->all());
    	$information->save();

    	return $this->response->item($information, new InformationTransformer())->setStatusCode(201);
    }

    public function update(Request $request, Information $information)
    {
    	$information->fill($request->all());
    	$information->update();

    	return $this->response->item($information, new InformationTransformer());
    }

    public function destroy(Information $information)
    {
    	$information->delete();
        return $this->response->noContent();
    }
}
